package com.twxm.breed.util;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Base64;

public class Base64Util {
    public static String getBase64(String path) throws IOException {
        // 读取图片文件
        File file = new File(path);
        byte[] bytes = Files.readAllBytes(file.toPath());

        // 编码为Base64字符串
        Base64.Encoder encoder = Base64.getEncoder();
        return encoder.encodeToString(bytes);
    }
}

